package entities;

import interfaze.SpaceInvadersGamingPanel;

import java.util.ArrayList;

@SuppressWarnings("serial")
public abstract class Enemy extends MovableEntity {
	int lastX;
	int lastY;
	ArrayList<Enemy> fila;
	/**
	 * 
	 * @param x
	 * @param y coordinates
	 * @param dx
	 * @param dy speed
	 * @param fila every enemy has a row, even though the bouncer is on its own in its row
	 * @param p the panel on which the enemy should be displayed
	 */
	public Enemy(int x, int y, int dx, int dy,ArrayList<Enemy> fila, SpaceInvadersGamingPanel p) {
		super(x, y, dx, dy);
		this.fila=fila;
		this.p=p;
	}
	/**
	 * this method checks the bounds of the defender and itself to see if they have collided, in case of doing so, the enemy is set to invisible and a hit is added to the defender
	 * @param d
	 */
	public void collidesWithDefender (Defender d){
		if(this.isVisible()){
			if(this.getBounds().intersects(d.getBounds())){
				d.hits++;
				this.setVisible(false);
			}
		}
	}
}
